package com.atguigu.gmall.product.mapper;

import com.atguigu.gmall.model.product.SpuSaleAttr;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.List;

@Mapper
public interface SpuSaleAttrMapper extends BaseMapper<SpuSaleAttr> {

    /*
    根据spuId,skuId 查询销售属性集合
select
    ssa.id ,ssa.spu_id, ssa.sale_attr_name,ssa.base_sale_attr_id,
    ssav.id sale_attr_value_id,
    ssav.sale_attr_value_name,
    sav.sku_id,
    IF(sav.sku_id IS NULL,0,1)  is_checked
from spu_sale_attr ssa inner join spu_sale_attr_value ssav
                        on ssa.spu_id=ssav.spu_id and ssa.base_sale_attr_id=ssav.base_sale_attr_id
                        left join sku_sale_attr_value sav
                        on sav.sale_attr_value_id=ssav.id and sav.sku_id=2
where ssa.spu_id=1
order by ssav.base_sale_attr_id,ssav.id;
     */
    List<SpuSaleAttr> selectSpuSaleAttrListCheckBySku(@Param("skuId") Long skuId,@Param("spuId") Long spuId);

    //根据spuId,获取销售属性+销售属性值
    /*
    sql语句
select
    ssa.id,
       ssa.spu_id,
       ssa.base_sale_attr_id,
       ssa.sale_attr_name,
       ssav.sale_attr_value_name,
       ssav.id sale_attr_value
from spu_sale_attr ssa inner join spu_sale_attr_value ssav
    on ssa.spu_id = ssav.spu_id and ssa.base_sale_attr_id=ssav.base_sale_attr_id
where ssa.spu_id= 1;
     */
    List<SpuSaleAttr> selectSpuSaleAttrList(Long spuId);
}
